// 装饰器 四种
/**
 *  @param {ClassDecorator} 类装饰器 
 *  @param {PropertyDecorator} 属性装饰器 
 *  @param {MethodDecorator} 方法装饰器 
 *  @param {ParameterDecorator} 参数装饰器 
 */

// 模拟一个Get装饰器
import axios from "axios";

const Get = (url:string) =>{
    return (tag:any,key:string,descriptor:any) => {
        let fn = descriptor.value;
        axios.get(url).then(res=>{
            fn(res,200)
        }).catch(err=>{
            fn(err,500)
        })
    }
}

class Test {
    constructor(){}
    @Get('https://m.baidu.com/sf?pd=topone_multi&atn=index&word=%E8%B1%86%E7%93%A3%E7%94%B5%E5%BD%B1top250&lid=15523406692866705893&key=bd%2FbPtJ7umUkuPF3fz0H4wbbfR%2FIB8veb6rRjTDeeqEVS%2F1TIXYtLVMW25bRVfFa%2BdvPb0y98zHLTQOcnk8wmJEQqtz76fON2BcDkEuHIdg%3D&top=%7B%22sfhs%22%3A1%7D&type=bpage')
    getData(res:any,status:any){
        console.log(res,status)
    }
}

const test:any = new Test()

test.getData()